<!DOCTYPE html>
<html>
<head>
  <title>单据管理</title>

  <meta name="keywords" content="keyword1,keyword2,keyword3">
  <meta name="description" content="this is my page">
  <meta name="content-type" content="text/html; charset=UTF-8">
  
  <!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
<link rel="stylesheet" href="/Hospital/lib/layui-v2.1.6/layui/css/layui.css" media="all">
<link rel="stylesheet" href="/Hospital/resources/css/table.css" media="all">
</head>
  
<body>
  	<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
		<legend>单据查看</legend>
	</fieldset>
	<table id="billTable" class="layui-table table" lay-filter="billTable"></table>
</body>
<script src="/Hospital/lib/jquery.min.js" charset="utf-8"></script>
<script src="/Hospital/lib/layui-v2.1.6/layui/layui.js" charset="utf-8"></script>
<script type="text/html" id="bar">
	<a class="layui-btn layui-btn-mini" lay-event="detail">详情</a>
</script>
<script>
	layui.use(['table','layer'],function(){
		var $ = layui.jquery;
		var table = layui.table;
		var layer = layui.layer;
		
		initTable();	//初始化Table
		listen();		//监听事件
		
		function initTable(){
			var height = window.innerHeight*0.8;
			var tableWidth=window.innerWidth*0.1;
			var shortWidth=window.innerWidth*0.07;
			var data = JSON.parse(localStorage.getItem("billTableCondition"));		
			localStorage.removeItem("billTableCondition");
			table.render({
				id : 'billTable',
				elem : '#billTable',
				page : true,
				center : true,
				limit : 10,
				height : height,
				cols :[[
		                {field:'clientName',width:tableWidth,title:'病人姓名',align:'center'},
		                {field:'operatorName',width:tableWidth,title:'单据负责人',align:'center'},
		                {field:'doctorName',width:tableWidth,title:'开单医生',align:'center'},
		                {field:'departmentName',width:tableWidth,title:'所属科室',align:'center'},
		                {field:'clinicName',width:tableWidth,title:'所属门诊',align:'center'},
		                {field:'totalCost',width:tableWidth,title:'总支出',align:'center'},
		                {field:'totalPrice',width:tableWidth,title:'总收入',align:'center'},
		                {field:'dateTime',width:tableWidth,title:'开单日期',align:'center'},
		                {field:'status',width:tableWidth,title:'支付情况',align:'center'},
		                {fixed:'right',width:shortWidth,align:'center',toolbar:'#bar'}
			    	   ]],
			   	url : "/Hospital/billController/checkBill",
			   	method : 'POST',
			   	where : data,
			   	response : {
			   		statusName:"code",
                	statusCode:200,
                	countName:'total',
                	msgName:"msg",
                	dataName:"result"
			   	}
			});
		}
		
		function listen(){
			table.on('tool(billTable)',function(obj){
				var data = obj.data;
				var layEvent = obj.event;
				data = {
					"billId" : data.billId
				};
				localStorage.setItem("billId", JSON.stringify(data));
				if(layEvent == 'detail'){
					layer.open({
						type : 2,
            			area : ['80%','90%'],
            			content : "/Hospital/views/billManager/billDetailTable.html"
					});
				}
			});
		}
	});
</script>
</html>
